<include file="Public/header.html"/>
<style>
    .layui-table{text-align: center;}
    .layui-table td, .layui-table th{text-align: center;}
    .layui-form-item .layui-input-inline{width: 170px;}
    .boxcolor1{display:inline-block;border-radius:3px;border:1px solid #108ee9;color:#108ee9;background:#bfebff;padding: 0 5px;font-size: 13px;}
    .boxcolor2{display:inline-block;border-radius:3px;border:1px solid #f9902c;color:#f9902c;background:#ffeedd;padding: 0 5px;font-size: 13px;}
    .boxcolor3{display:inline-block;border-radius:3px;border:1px solid #81b82e;color:#81b82e;background:#eefadd;padding: 0 5px;font-size: 13px;}
    .boxcolor4{display:inline-block;border-radius:3px;border:1px solid #f44759;color:#f44759;background:#fcdee1;padding: 0 5px;font-size: 13px;}
    .boxcolor5{display:inline-block;border-radius:3px;border:1px solid #c676fd;color:#c676fd;background:#f4e3ff;padding: 0 5px;font-size: 13px;}
    .boxcolor6{display:inline-block;border-radius:3px;border:1px solid #999;color:#999;background:#fff;padding: 0 5px;font-size: 13px;}
    .fws_color1{display:inline-block;border-radius:3px;color:#fff;background:#008aea;padding: 0 5px;}
    .fws_color2{display:inline-block;border-radius:3px;color:#fff;background:#ef2c2c;padding: 0 5px;}
    .fws_color3{display:inline-block;border-radius:3px;color:#fff;background:#004d98;padding: 0 5px;}
</style>
</head>
<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
          <a><cite>首页</cite></a>
          <a><cite>订单管理</cite></a>
          <a><cite>订单列表</cite></a>
        </span>
       <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;height:30px;padding: 0 15px;"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <!--<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" style="margin-left: 15px;">
	  	<ul class="layui-tab-title">
		    <li class="layui-this" >
				<a href="{:U('Home/Web/Order/order_list')}">订单列表</a>
			</li>
	  	</ul>
  	</div>-->
    <div class="x-body">
		<form class="layui-form x-center" action="{:U('Home/Web/Order/order_list',array('flag'=>$flag))}"  method="post"  style="width:95%;margin-left: 5%;">
			<div class="layui-form-pane" style="margin-top: 15px;">
				<div class="layui-form-item">   
					<div class="layui-input-inline">
	                  	<input type="text" name="title" value="{$title}"  placeholder="请输入项目名称" autocomplete="off" class="layui-input">
	                </div>
					<div class="layui-input-inline">
	                  	<input type="text" name="nickname" value="{$nickname}"  placeholder="请输入微信昵称" autocomplete="off" class="layui-input">
	                </div>
					<div class="layui-input-inline" style="width: 140px;">
						<input type="text" name="ordernum" placeholder="请输入订单号" value="{$ordernum}"  autocomplete="off" class="layui-input">
					</div>
					<?php if(true){ ?>
	                <div class="layui-input-inline">
	                  	<input type="text" name="phone" value="{$phone}"  placeholder="请输入手机号" autocomplete="off" class="layui-input">
	                </div>
					<div class="layui-input-inline">
						<select name="status">
							<option value="">请选择状态</option>
							<option value="0" <?php if($status === 0){ echo 'selected'; } ?> >待审核</option>
	                        <option value="1" <?php if($status === 1){ echo 'selected'; } ?> >T0审核</option>
	                        <option value="2" <?php if($status === 2){ echo 'selected'; } ?> >T1审核</option>
	                        <option value="3" <?php if($status === 3){ echo 'selected'; } ?> >T2审核</option>
	                        <option value="4" <?php if($status === 4){ echo 'selected'; } ?> >T3审核</option>
	                        <option value="5" <?php if($status === 5){ echo 'selected'; } ?> >T4审核</option>
	                        <option value="6" <?php if($status === 6){ echo 'selected'; } ?> >T5审核</option>
	                        <option value="-1" <?php if($status === -1){ echo 'selected'; } ?> >审核失败</option>
	                        <option value="-2" <?php if($status === -2){ echo 'selected'; } ?> >已取消</option>
						</select>
					</div>
					<?php }else{ ?>
					<div class="layui-input-inline">
						<select name="status" id="status" lay-verify="required" lay-filter="type">
							<option value="0">请选择状态</option>
							<option value="1" <?php if($status == 0){ echo 'selected'; } ?> >审核中</option>
							<option value="2" <?php if($status == -1){ echo 'selected'; } ?> >已拒绝</option>
							<option value="3" <?php if($status == 1){ echo 'selected'; } ?> >已通过</option>
						</select>
					</div>
					<?php } ?>
					<div class="layui-input-inline" style="width:80px">
						<button class="layui-btn" type="submit"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
					</div>
				</div>
			</div> 
		</form>
		<form id="delform" class="layui-form">    	 	
			<table class="layui-table">     	 		
				<thead>
					<tr>
						<th>ID</th>
						<th>微信昵称</th>
						<th>项目名称</th>
						<?php if(true){ ?>
						<th>姓名</th>
						<th>手机号</th>
						<?php }else{ ?>
						<th>图片凭证</th>
						<th>文字凭证</th>
						<?php } ?>
						<th>订单号</th>
						<th>项目佣金</th>
						<th>状态</th>
						<th>操作时间</th>
						<th>操作</th>
					</tr>
				</thead>
		  
				<tbody id="formdata">
					<volist name="list" id="v">	
					<tr>
						<td>{$v.id}</td>
						<td>{$v.nickname}</td>
						<td>{$v.title}</td>
						<?php if(true){ ?>
						<td>{$v.name}</td>
						<td>{$v.phone}</td>
						<?php }else{ ?>
						<td>
							<?php foreach(json_decode($v['img'],true) as $val){ ?>
							<img src="{$val}" alt="" />
							<?php } ?>
						</td>
						<td>{$v.text}</td>
						<?php } ?>
						<td>{$v.order_num}</td>
						<td>{$v.reprice}</td>
						<?php if(true){ ?>
						<td>
							<?php if($v['status']==0){
		                    	echo '<span class="boxcolor2">待审核</span>';
		                    }elseif($v['status']==1){
		                        echo '<span class="boxcolor4">T0审核</span>';
		                    }elseif($v['status']==2){
		                        echo '<span class="boxcolor4">T1审核</span>';
		                    }elseif($v['status']==3){
		                        echo '<span class="boxcolor4">T2审核</span>';
		                    }elseif($v['status']==4){
		                        echo '<span class="boxcolor4">T3审核</span>';
		                    }elseif($v['status']==5){
		                        echo '<span class="boxcolor4">T4审核</span>';
		                    }elseif($v['status']==6){
		                        echo '<span class="boxcolor4">T5审核</span>';
		                    }elseif($v['status']==-1){
		                        echo '<span class="boxcolor5">审核失败</span>';
		                    }elseif($v['status']==-2){
		                        echo '<span class="boxcolor6">已取消</span>';
		                    }?>
						</td>
						<?php }else{ ?>
						<td>
							<if condition="$v['status'] eq 0">
								<font color="#0000FF">审核中</font>
							<elseif condition="$v['status'] eq -1" />
								<font color="#c22525">已拒绝</font>
							<elseif condition="$v['status'] eq 1" />
								<font color="#008000">已通过</font>
							</if>
						</td>	
						<?php } ?>	
						<td><?php echo date('Y-m-d H:i:s', $v['update_time']); ?></td>                   
						<td class="td-manage">
							<?php if($v['status']!=0 && $v['status']!=-2){ ?>
							<span class="layui-btn layui-btn-xs layui-btn-green" onclick="order_detail('审核记录','{:U('Home/Web/Order/order_detail',array('id'=>$v['id']))}','800','')">审核记录</span>
							<?php } ?>
							<if condition="$v['status'] eq 0">
								<span class="layui-btn layui-btn-xs layui-btn-normal"  onclick="do_order('{$v['id']}')">审核</span>
							</if>	
						</td>
					</tr>
					</volist>  
				</tbody>
			</table>
			<span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
		</form>       
		<div id="page"></div>
	</div>
    <include file="Public/footer.html"/>
    <script>    	
        layui.use(['form','element','laypage','layer'], function(){
          	var laypage = layui.laypage;//分页
          	var layer = layui.layer;//弹出层
          	var form = layui.form;
          	$ = layui.jquery; 
		  
		  	laypage.render({
			   	elem: 'page',
			   	count: '{$count}',
			   	limit: '{$limit}',
			   	curr : '{$page}', 
			   	jump: function(obj, first){
				   	if(!first){ 
				    	var $purl = "{:U('Home/Web/Order/order_list',array('page'=>'pageval','status'=>$status,'ordernum'=>$ordernum,'title'=>$title,'nickname'=>$nickname,'phone'=>$phone,'flag'=>$flag))}"
				    	window.location.href= $purl.replace('pageval',obj.curr);  			
				   	}
				}
		  	});
        });
        
        function do_order(id){
		    layer.confirm('请选择同意或拒绝', {
		      btn: ['同意', '拒绝'] //可以无限个按钮
		    }, function(index, layero){
		    	layer.closeAll();
		    	var loading = layer.msg('加载中...', {icon: 16,shade: 0.3,time: 60*1000});
		    	$.ajax({
		    	    type: "POST",
		    	    url: "{:U('Home/Web/Order/do_order')}", 
		    	    data: {"id": id,"status":1},
		    	    success: function (data) {
		    	        layer.close(loading);
		    	        if(data=='1'){
		    	        	parent.layer.msg('提交成功！', {icon: 1,offset: '40%',time:1500,shade: 0.3},function(){
		    	        		location.reload();
		    	        	});   
		    	        }else if(data=='2'){
		    	        	parent.layer.msg('提交失败！', {icon: 2,offset: '40%',time:1500,shade: 0.3});
		    	        }else{
		    	        	parent.layer.msg(data, {icon: 2,offset: '40%',time:1500,shade: 0.3});
		    	        }
		    	    }
		    	});
		    }, function(index, layero){
				var loading = layer.msg('加载中...', {icon: 16,shade: 0.3,time: 60*1000});
				$.ajax({
					type: "POST", 
					url: "{:U('Home/Web/Order/do_order')}", 
					data: {"id": id,"status":-1},
					success: function (data) {
					layer.close(loading);
						if(data=='1'){
							parent.layer.msg('提交成功！', {icon: 1,offset: '40%',time:1500,shade: 0.3},function(){
								location.reload();
							});   
						}else if(data=='2'){
							parent.layer.msg('提交失败！', {icon: 2,offset: '40%',time:1500,shade: 0.3});
						}else{
							parent.layer.msg(data, {icon: 2,offset: '40%',time:1500,shade: 0.3});
						}
					}
				});
		    });
			
		}
        
		function order_detail(title,url,w,h){
			if (title == null || title == '') {
				title=false;
			};
			if (url == null || url == '') {
				url="404.html";
			};
			if (w == null || w == '') {
				w=800;
			};
			if (h == null || h == '') {
				h=($(window).height() - 50);
			};
			
			var index = layer.open({
				id:'ch',
				type: 2,
				area: [w+'px',h +'px'],
				fix: false, //不固定
				maxmin: true,
				shadeClose: true,
				shade:0.4,
				title: title,
				content: url,
				btn: [] ,
			});
		}
	</script>  
	</body>
</html>
